package eureka.config.timezone;

import eureka.model.enums.ApplicationRunnerOrderEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;

import java.util.TimeZone;

/**
 * 描述
 *
 * @author 米泽鹏
 * @since 2023/1/4 下午 6:06
 */
@Component
@Slf4j
public class TimezoneConfig implements ApplicationRunner, Ordered {

	@Override
	public void run(ApplicationArguments args) {
		// 设置默认时区
		TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
//		System.setProperty("user.timezone", "Asia/Shanghai");
		log.info("设置默认时区：Asia/Shanghai");
	}

	@Override
	public int getOrder() {
		return ApplicationRunnerOrderEnum.TIMEZONE_CONFIG.getOrder();
	}

}
